﻿using System;
using System.IO;
using System.Collections.Generic;
using ComplexNumberPresentation;

namespace Logger
{
    public class HtmlLogger : ILogger
    {
        private const String LOG_FILE = "LOG.html";
        private List<String> logText;

        public HtmlLogger()
        {
            logText = new List<String>();
        }

        public String getLog()
        {
            String log = "";
            foreach (var msg in logText)
            {
                log += msg + "\r\n";
            }
            return log;
        }

        public List<String> getLogMessages()
        {
            return logText;
        }

        public void addLogMessage(String message)
        {
            logText.Add(message);
        }

        public void Write()
        {
            var file = new StreamWriter(LOG_FILE, false);
            foreach (var msg in logText) {
                file.WriteLine(msg + "<br>");
            }
            file.Close();
        }
    }
}
